Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce gc alloc #23

Merged
merged 1 commit into from
Feb 18, 2024
Merged

Reduce gc alloc #23

merged 1 commit into from
Feb 18, 2024

Conversation

takahiro0327
Copy link
Contributor

@takahiro0327 takahiro0327 commented Feb 18, 2024

Nice to meet you.
I am an engineer who has recently been looking into ways to improve the load times on Koikatsu.
There was a bit of heavy code in SexFace. This is a PR that fixes that.
Please merge if you don't mind.
Thanks for the nice plugin.

The internal alloc of mesh.vertices in the following code from AddLopsided was slowing things down.
One call to mesh.vertices is not a significant load, but the number of calls seems to have been too many.
image

I added the following logs before and after the series of processes and measured the time. it took 0.5 to 0.7 seconds per character.
スクリーンショット 2024-02-18 221401

GCBytes 53051392 Time 0.582132
GCBytes 42024960 Time 0.6396368
GCBytes -91897856 Time 0.7382355
GCBytes -88330240 Time 0.7776159

I think the GCBytes is negative because the garbage collector was activated.

I was able to get around this by first getting mesh.vertices and then using it around.

GCBytes 1568768 Time 0.0056536
GCBytes 1564672 Time 0.0046379
GCBytes 1564672 Time 0.0045126
GCBytes 1564672 Time 0.0041868

This modification reduces the loading time for a scene with about 20 characters in place from 50 to 45 seconds.

@Sauceke
Copy link
Owner

Sauceke commented Feb 18, 2024

Fair point, I wasn't aware that getting the vertex list had this overhead.
Tested this on some high-poly headmods, and it seems to have reduced 3-4 second loading times (for the blendshapes) to basically nothing.
Great find, thank you!

@Sauceke Sauceke merged commit 7fbc5dc into Sauceke:main Feb 18, 2024
1 check passed
@takahiro0327 takahiro0327 deleted the fix_gcalloc branch February 19, 2024 01:12
@takahiro0327
Copy link
Contributor Author

takahiro0327 commented Feb 19, 2024

Thanks merge!

I didn't know this either until I discovered this.
I thought either no memory was allocated or if it was, it was only the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants